<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
 <meta>
  <!-- Stylesheets -->
  <link href="../web.css" type="text/css" rel="stylesheet"></link>
  <link href="../pygmentize.css" type="text/css" rel="stylesheet"></link>
  <title>VLFeat - Documentation - C API</title>
  <link rel="stylesheet" type="text/css" href="../doxygen.css"></style>

  <!-- Scripts-->
  
 </meta>

 <!-- Body Start -->
 <body>
  <div id="header">
   <!-- Google CSE Search Box Begins -->
   <form action="http://www.vlfeat.org/search.html" method="get" id="cse-search-box" enctype="application/x-www-form-urlencoded">
    <div>
     <input type="hidden" name="cx" value="003215582122030917471:oq23albfeam"></input>
     <input type="hidden" name="cof" value="FORID:11"></input>
     <input type="hidden" name="ie" value="UTF-8"></input>
     <input type="text" name="q" size="31"></input>
     <input type="submit" name="sa" value="Search"></input>
    </div>
   </form>
   <script src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=en" xml:space="preserve" type="text/javascript"></script>
   <!-- Google CSE Search Box Ends -->
   <h1><a shape="rect" href="../index.html" class="plain"><span id="vlfeat">VLFeat</span><span id="dotorg">.org</span></a></h1>
  </div>
  <div id="headbanner">
   Documentation - C API
  </div>
  <div id="pagebody">
   <div id="sidebar"> <!-- Navigation Start -->
    <ul>
<li><a href="../index.html">Home</a>
</li>
<li><a href="../download.html">Download</a>
</li>
<li><a href="../doc.html">Documentation</a>
<ul>
<li><a href="../mdoc/mdoc.html">Matlab API</a>
</li>
<li><a href="index.html" class='active' >C API</a>
</li>
<li><a href="../man/man.html">Man pages</a>
</li>
</ul></li>
<li><a href="../overview/tut.html">Tutorials</a>
</li>
<li><a href="../applications/apps.html">Applications</a>
</li>
</ul>

   </div> <!-- sidebar -->
   <div id="content">
    
    <link rel="stylesheet" type="text/css" href="../doxygen.css"></style>
    <div class="doxygen">
<div>
<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a>  </div>
  <div class="headertitle">
<div class="title">pgm.h File Reference</div>  </div>
</div>
<div class="contents">

<p>Portable graymap format (PGM) parser.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &quot;<a class="el" href="generic_8h.html">generic.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="mathop_8h.html">mathop.h</a>&quot;</code><br/>
<code>#include &lt;stdio.h&gt;</code><br/>
</div><table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structVlPgmImage.html">VlPgmImage</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">PGM image meta data.  <a href="structVlPgmImage.html#details">More...</a><br/></td></tr>
<tr><td colspan="2"><h2><a name="define-members"></a>
Defines</h2></td></tr>
<tr><td colspan="2"><div class="groupHeader">PGM parser error codes</div></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pgm_8h.html#aa0566322098c2b529a027f1f00a9b586">VL_ERR_PGM_INV_HEAD</a>&#160;&#160;&#160;101</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pgm_8h.html#ad7d582518c6bbb8409649207443b0d42">VL_ERR_PGM_INV_META</a>&#160;&#160;&#160;102</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pgm_8h.html#a4623e454d921cad79d89ad3783d46739">VL_ERR_PGM_INV_DATA</a>&#160;&#160;&#160;103</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pgm_8h.html#a8d09e3f8171e1531db2045fe33c023f5">VL_ERR_PGM_IO</a>&#160;&#160;&#160;104</td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td colspan="2"><div class="groupHeader">Core operations</div></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pgm_8h.html#a829c23407220c6e7953ee45cca900565">vl_pgm_extract_head</a> (FILE *f, <a class="el" href="structVlPgmImage.html">VlPgmImage</a> *im)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Extract PGM header from stream.  <a href="#a829c23407220c6e7953ee45cca900565"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pgm_8h.html#a5ff673e681338e79a1c1591179504b5f">vl_pgm_extract_data</a> (FILE *f, <a class="el" href="structVlPgmImage.html">VlPgmImage</a> const *im, void *data)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Extract PGM data from stream.  <a href="#a5ff673e681338e79a1c1591179504b5f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pgm_8h.html#a418f48a6aa8471ccaaf79640f4298d0a">vl_pgm_insert</a> (FILE *f, <a class="el" href="structVlPgmImage.html">VlPgmImage</a> const *im, void const *data)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Insert a PGM image into a stream.  <a href="#a418f48a6aa8471ccaaf79640f4298d0a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pgm_8h.html#aa8e8f55f42c5c16dba6b8ef1f5afa240">vl_pgm_get_npixels</a> (<a class="el" href="structVlPgmImage.html">VlPgmImage</a> const *im)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Get PGM image number of pixels.  <a href="#aa8e8f55f42c5c16dba6b8ef1f5afa240"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pgm_8h.html#a1994872b33933dc4f60a6108a56c88a1">vl_pgm_get_bpp</a> (<a class="el" href="structVlPgmImage.html">VlPgmImage</a> const *im)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Get PGM image bytes per pixel.  <a href="#a1994872b33933dc4f60a6108a56c88a1"></a><br/></td></tr>
<tr><td colspan="2"><div class="groupHeader">Helper functions</div></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pgm_8h.html#af2e33d504690aeff3eeb3e035727df9b">vl_pgm_write</a> (char const *name, <a class="el" href="host_8h.html#a38fbd9a3cf53dfc9a5650c38497b7d35">vl_uint8</a> const *data, int width, int height)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Write bytes to a PGM file.  <a href="#af2e33d504690aeff3eeb3e035727df9b"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pgm_8h.html#a3751d1ee6548a567dd0860dfe921b498">vl_pgm_write_f</a> (char const *name, float const *data, int width, int height)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Write floats to PGM file.  <a href="#a3751d1ee6548a567dd0860dfe921b498"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pgm_8h.html#a5814312e5e026dc51396dd09b864fb8b">vl_pgm_read_new</a> (char const *name, <a class="el" href="structVlPgmImage.html">VlPgmImage</a> *im, <a class="el" href="host_8h.html#a38fbd9a3cf53dfc9a5650c38497b7d35">vl_uint8</a> **data)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Read a PGM file.  <a href="#a5814312e5e026dc51396dd09b864fb8b"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pgm_8h.html#a8b9eb82a66e8cb72bdf6ab3ad1d30015">vl_pgm_read_new_f</a> (char const *name, <a class="el" href="structVlPgmImage.html">VlPgmImage</a> *im, float **data)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Read floats from a PGM file.  <a href="#a8b9eb82a66e8cb72bdf6ab3ad1d30015"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>This module implements basic input and ouptut of images in PGM format.</p>
<p>Extracting an image encoded in PGM format from an imput file stream involves the following steps:</p>
<ul>
<li>use <a class="el" href="pgm_8h.html#a829c23407220c6e7953ee45cca900565" title="Extract PGM header from stream.">vl_pgm_extract_head</a> to extract the image meta data (size and bit depth);</li>
<li>allocate a buffer to store the image data;</li>
<li>use <a class="el" href="pgm_8h.html#a5ff673e681338e79a1c1591179504b5f" title="Extract PGM data from stream.">vl_pgm_extract_data</a> to extract the image data to the allocated buffer.</li>
</ul>
<p>Writing an image in PGM format to an ouptut file stream can be done by using <a class="el" href="pgm_8h.html#a418f48a6aa8471ccaaf79640f4298d0a" title="Insert a PGM image into a stream.">vl_pgm_insert</a>.</p>
<p>To quickly read/write a PGM image from/to a given file, use <a class="el" href="pgm_8c.html#a5814312e5e026dc51396dd09b864fb8b" title="Read a PGM file.">vl_pgm_read_new()</a> and <a class="el" href="pgm_8c.html#af2e33d504690aeff3eeb3e035727df9b" title="Write bytes to a PGM file.">vl_pgm_write()</a>. To to the same from a buffer in floating point format use <a class="el" href="pgm_8c.html#a8b9eb82a66e8cb72bdf6ab3ad1d30015" title="Read floats from a PGM file.">vl_pgm_read_new_f()</a> and <a class="el" href="pgm_8c.html#a3751d1ee6548a567dd0860dfe921b498" title="Write floats to PGM file.">vl_pgm_write_f()</a>.</p>
<dl class="author"><dt><b>Author:</b></dt><dd>Andrea Vedaldi </dd></dl>
</div><hr/><h2>Define Documentation</h2>
<a class="anchor" id="a4623e454d921cad79d89ad3783d46739"></a><!-- doxytag: member="pgm.h::VL_ERR_PGM_INV_DATA" ref="a4623e454d921cad79d89ad3783d46739" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define VL_ERR_PGM_INV_DATA&#160;&#160;&#160;103</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Invalid PGM data section </p>

</div>
</div>
<a class="anchor" id="aa0566322098c2b529a027f1f00a9b586"></a><!-- doxytag: member="pgm.h::VL_ERR_PGM_INV_HEAD" ref="aa0566322098c2b529a027f1f00a9b586" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define VL_ERR_PGM_INV_HEAD&#160;&#160;&#160;101</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Invalid PGM header section </p>

</div>
</div>
<a class="anchor" id="ad7d582518c6bbb8409649207443b0d42"></a><!-- doxytag: member="pgm.h::VL_ERR_PGM_INV_META" ref="ad7d582518c6bbb8409649207443b0d42" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define VL_ERR_PGM_INV_META&#160;&#160;&#160;102</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Invalid PGM meta section </p>

</div>
</div>
<a class="anchor" id="a8d09e3f8171e1531db2045fe33c023f5"></a><!-- doxytag: member="pgm.h::VL_ERR_PGM_IO" ref="a8d09e3f8171e1531db2045fe33c023f5" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define VL_ERR_PGM_IO&#160;&#160;&#160;104</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Generic I/O error </p>

</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="a5ff673e681338e79a1c1591179504b5f"></a><!-- doxytag: member="pgm.h::vl_pgm_extract_data" ref="a5ff673e681338e79a1c1591179504b5f" args="(FILE *f, VlPgmImage const *im, void *data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int vl_pgm_extract_data </td>
          <td>(</td>
          <td class="paramtype">FILE *&#160;</td>
          <td class="paramname"><em>f</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structVlPgmImage.html">VlPgmImage</a> const *&#160;</td>
          <td class="paramname"><em>im</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">f</td><td>input file. </td></tr>
    <tr><td class="paramname">im</td><td>PGM image descriptor. </td></tr>
    <tr><td class="paramname">data</td><td>data buffer to fill.</td></tr>
  </table>
  </dd>
</dl>
<p>The function extracts from the file <em>f</em> the data section of an image encoded in PGM format. The function fills the buffer <em>data</em> according. The buffer <em>data</em> should be <a class="el" href="pgm_8c.html#aa8e8f55f42c5c16dba6b8ef1f5afa240" title="Get PGM image number of pixels.">vl_pgm_get_npixels()</a> by <a class="el" href="pgm_8c.html#a1994872b33933dc4f60a6108a56c88a1" title="Get PGM image bytes per pixel.">vl_pgm_get_bpp()</a> bytes large.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>error code. </dd></dl>

</div>
</div>
<a class="anchor" id="a829c23407220c6e7953ee45cca900565"></a><!-- doxytag: member="pgm.h::vl_pgm_extract_head" ref="a829c23407220c6e7953ee45cca900565" args="(FILE *f, VlPgmImage *im)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int vl_pgm_extract_head </td>
          <td>(</td>
          <td class="paramtype">FILE *&#160;</td>
          <td class="paramname"><em>f</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structVlPgmImage.html">VlPgmImage</a> *&#160;</td>
          <td class="paramname"><em>im</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">f</td><td>input file. </td></tr>
    <tr><td class="paramname">im</td><td>image structure to fill.</td></tr>
  </table>
  </dd>
</dl>
<p>The function extracts from the file <em>f</em> the meta-data section of an image encoded in PGM format. The function fills the structure <a class="el" href="structVlPgmImage.html" title="PGM image meta data.">VlPgmImage</a> accordingly.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>error code. The error may be either #VL_PGM_INV_HEAD or #VL_PGM_INV_META depending whether the error occurred in decoding the header or meta section of the PGM file. </dd></dl>

</div>
</div>
<a class="anchor" id="a1994872b33933dc4f60a6108a56c88a1"></a><!-- doxytag: member="pgm.h::vl_pgm_get_bpp" ref="a1994872b33933dc4f60a6108a56c88a1" args="(VlPgmImage const *im)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int vl_pgm_get_bpp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVlPgmImage.html">VlPgmImage</a> const *&#160;</td>
          <td class="paramname"><em>im</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">im</td><td>PGM image descriptor.</td></tr>
  </table>
  </dd>
</dl>
<p>The function returns the number of bytes for each pixel of the PGM image <em>im</em>.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>number of bytes per pixel. </dd></dl>

</div>
</div>
<a class="anchor" id="aa8e8f55f42c5c16dba6b8ef1f5afa240"></a><!-- doxytag: member="pgm.h::vl_pgm_get_npixels" ref="aa8e8f55f42c5c16dba6b8ef1f5afa240" args="(VlPgmImage const *im)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int vl_pgm_get_npixels </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structVlPgmImage.html">VlPgmImage</a> const *&#160;</td>
          <td class="paramname"><em>im</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">im</td><td>PGM image descriptor.</td></tr>
  </table>
  </dd>
</dl>
<p>The functions returns the number of pixels of the PGM image <em>im</em>.</p>
<p>To calculate the image data size in bytes, this value must be multiplied by the number of byte per pixels (see <a class="el" href="pgm_8c.html#a1994872b33933dc4f60a6108a56c88a1" title="Get PGM image bytes per pixel.">vl_pgm_get_bpp()</a>).</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>number of pixels of the image. </dd></dl>

</div>
</div>
<a class="anchor" id="a418f48a6aa8471ccaaf79640f4298d0a"></a><!-- doxytag: member="pgm.h::vl_pgm_insert" ref="a418f48a6aa8471ccaaf79640f4298d0a" args="(FILE *f, VlPgmImage const *im, void const *data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int vl_pgm_insert </td>
          <td>(</td>
          <td class="paramtype">FILE *&#160;</td>
          <td class="paramname"><em>f</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structVlPgmImage.html">VlPgmImage</a> const *&#160;</td>
          <td class="paramname"><em>im</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void const *&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">f</td><td>output file. </td></tr>
    <tr><td class="paramname">im</td><td>PGM image meta-data. </td></tr>
    <tr><td class="paramname">data</td><td>image data. </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>error code. </dd></dl>

</div>
</div>
<a class="anchor" id="a5814312e5e026dc51396dd09b864fb8b"></a><!-- doxytag: member="pgm.h::vl_pgm_read_new" ref="a5814312e5e026dc51396dd09b864fb8b" args="(char const *name, VlPgmImage *im, vl_uint8 **data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int vl_pgm_read_new </td>
          <td>(</td>
          <td class="paramtype">char const *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structVlPgmImage.html">VlPgmImage</a> *&#160;</td>
          <td class="paramname"><em>im</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="host_8h.html#a38fbd9a3cf53dfc9a5650c38497b7d35">vl_uint8</a> **&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">name</td><td>file name. </td></tr>
    <tr><td class="paramname">im</td><td>a pointer to the PGM image structure to fill. </td></tr>
    <tr><td class="paramname">data</td><td>a pointer to the pointer to the allocated buffer.</td></tr>
  </table>
  </dd>
</dl>
<p>The function reads a PGM image from file <em>name</em> and initializes the structure <em>im</em> and the buffer <em>data</em> accordingly.</p>
<p>The ownership of the buffer <em>data</em> is transfered to the caller. <em>data</em> should be freed by means of <a class="el" href="generic_8h.html#ae070a0a4d3d367a1ba8308644c88ada3" title="Call customizable free function.">vl_free()</a>.</p>
<dl class="bug"><dt><b><a class="el" href="bug.html#_bug000001">Bug:</a></b></dt><dd>Only PGM files with 1 BPP are supported.</dd></dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>error code. </dd></dl>

</div>
</div>
<a class="anchor" id="a8b9eb82a66e8cb72bdf6ab3ad1d30015"></a><!-- doxytag: member="pgm.h::vl_pgm_read_new_f" ref="a8b9eb82a66e8cb72bdf6ab3ad1d30015" args="(char const *name, VlPgmImage *im, float **data)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int vl_pgm_read_new_f </td>
          <td>(</td>
          <td class="paramtype">char const *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structVlPgmImage.html">VlPgmImage</a> *&#160;</td>
          <td class="paramname"><em>im</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float **&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">name</td><td>file name. </td></tr>
    <tr><td class="paramname">im</td><td>a pointer to the PGM image structure to fill. </td></tr>
    <tr><td class="paramname">data</td><td>a pointer to the pointer to the allocated buffer.</td></tr>
  </table>
  </dd>
</dl>
<p>The function reads a PGM image from file <em>name</em> and initializes the structure <em>im</em> and the buffer <em>data</em> accordingly. The buffer <em>data</em> is an array of floats in the range [0, 1].</p>
<p>The ownership of the buffer <em>data</em> is transfered to the caller. <em>data</em> should be freed by means of <a class="el" href="generic_8h.html#ae070a0a4d3d367a1ba8308644c88ada3" title="Call customizable free function.">vl_free()</a>.</p>
<dl class="bug"><dt><b><a class="el" href="bug.html#_bug000002">Bug:</a></b></dt><dd>Only PGM files with 1 BPP are supported.</dd></dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>error code. </dd></dl>

</div>
</div>
<a class="anchor" id="af2e33d504690aeff3eeb3e035727df9b"></a><!-- doxytag: member="pgm.h::vl_pgm_write" ref="af2e33d504690aeff3eeb3e035727df9b" args="(char const *name, vl_uint8 const *data, int width, int height)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int vl_pgm_write </td>
          <td>(</td>
          <td class="paramtype">char const *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="host_8h.html#a38fbd9a3cf53dfc9a5650c38497b7d35">vl_uint8</a> const *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>width</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>height</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">name</td><td>file name. </td></tr>
    <tr><td class="paramname">data</td><td>data to write. </td></tr>
    <tr><td class="paramname">width</td><td>width of the image. </td></tr>
    <tr><td class="paramname">height</td><td>height of the image.</td></tr>
  </table>
  </dd>
</dl>
<p>The function dumps the image <em>data</em> to the PGM file of the specified name. This is an helper function simplifying the usage of <a class="el" href="pgm_8c.html#a418f48a6aa8471ccaaf79640f4298d0a" title="Insert a PGM image into a stream.">vl_pgm_insert()</a>.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>error code. </dd></dl>

</div>
</div>
<a class="anchor" id="a3751d1ee6548a567dd0860dfe921b498"></a><!-- doxytag: member="pgm.h::vl_pgm_write_f" ref="a3751d1ee6548a567dd0860dfe921b498" args="(char const *name, float const *data, int width, int height)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int vl_pgm_write_f </td>
          <td>(</td>
          <td class="paramtype">char const *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">float const *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>width</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>height</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">name</td><td>file name. </td></tr>
    <tr><td class="paramname">data</td><td>data to write. </td></tr>
    <tr><td class="paramname">width</td><td>width of the image. </td></tr>
    <tr><td class="paramname">height</td><td>height of the image.</td></tr>
  </table>
  </dd>
</dl>
<p>The function dumps the image <em>data</em> to the PGM file of the specified name. The data is re-scaled to fit in the range 0-255. This is an helper function simplifying the usage of <a class="el" href="pgm_8c.html#a418f48a6aa8471ccaaf79640f4298d0a" title="Insert a PGM image into a stream.">vl_pgm_insert()</a>.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>error code. </dd></dl>

</div>
</div>
</div>
     <!-- Doc Here -->
    </div>
   
   </div>
   <div class="clear">&nbsp;</div>
  </div> <!-- pagebody -->
  <div id="footer">
   &copy; 2007-12 Andrea Vedaldi and Brian Fulkerson
  </div> <!-- footer -->

  <!-- Google Analytics Begins -->
  <script xml:space="preserve" type="text/javascript">
   //<![CDATA[
    var localre = /vlfeat.org/;
    if(document.location.host.search(localre) != -1)
    {
   var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
   document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
   }
   //]]>
  </script>
  <script xml:space="preserve" type="text/javascript">
    //<![CDATA[
    var localre = /vlfeat.org/;
    if(document.location.host.search(localre) != -1)
    {

   try {
   var pageTracker = _gat._getTracker("UA-4936091-2");
   pageTracker._trackPageview();
   } catch(err) {}

   }
   //]]>
  </script>
  <!-- Google Analytics Ends -->
 </body>
</html>

 
